/**
 * Created by lxy_920912 on 27/03/2017.
 */
var groupAnagrams = function(strs) {
    var obj = {};

    for(var i = 0;i < strs.length;i++){
        var key = strs[i].split('').sort().join('');
        if(obj.hasOwnProperty(key)){
            obj[key].push(strs[i]);
        }else{
            obj[key] = [];
            obj[key].push(strs[i]);
        }
    }
    var result = [];
    for(var i in obj){
        result.push(obj[i]);
    }
    return result;

};
groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]);